package engine;

import java.text.DecimalFormat;

/**
 *
 * @author Johnny
 */
public class Node {
    private int id;
    private float x;
    private float y;
    private String name;

    public Node(int id) {
        this(id, 0, 0, "");
    }

    public Node(int id, float x, float y, String name) {
        this.id = id;
        this.x = x;
        this.y = y;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public float getX() {
        return x;
    }

    public float getY() {
        return y;
    }

    // Package level methods seen only by the Engine
    
    void setName(String name) {
        this.name = name;
    }

    void setPos(float x, float y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public String toString() {
//        DecimalFormat dformat = new DecimalFormat("0.00");
//
//        StringBuffer sb = new StringBuffer();
//        sb.append(id);
//        sb.append(" ");
//        sb.append(name);
//        sb.append("(");
//        sb.append(dformat.format(x));
//        sb.append(",");
//        sb.append(dformat.format(y));
//        sb.append(")");
//
//        return sb.toString();
        return name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Node other = (Node) obj;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + this.id;
        return hash;
    }

    @Override
    public Object clone() {
        return new Node(id, x, y, name);
    }
}
